//////////////////
/// mkI - Base ///
//////////////////

// Base includes
#include "../../Base/Independent/mkErrno.h"
#include "../../Base/Windows/mkDebugWin.h"

namespace mk
{

Errno ErrnoMessage
(
    Errno err,
    char const* function,
    char const* format,
    ...
)
{
    // Format the final message
    va_list args;
    va_start(args, format);
    char const* outputString = FormatOutputString(format, args);
    va_end(args);

    charW const* errnoString =         FormatOutputString
        (
            mkText( "Function: %hs\nError:    %hs\nMessage:  %hs"),
            function, GetErrnoString(err),outputString
        );

    // Format the message
    TraceUnformatted("\n----- mk Errno --------------------------------------");
    OutputDebugStringW( errnoString );
    TraceUnformatted("\n-----------------------------------------------------\n");

    // Return the error
    return err;
}

} // namespace mk

